package com.etc.service;

import com.etc.entity.Notice;
import com.etc.entity.Tips;
import com.etc.mapper.TipsMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

@Service
public class TipsService {

    @Autowired
    private TipsMapper tipsMapper;

    public String tipsAdd(@Param("tips_title")String tips_title, @Param("tips_content")String tips_content){
        Tips tips = new Tips();
        tips.setTips_title(tips_title);
        tips.setTips_content(tips_content);
        tips.setTips_date(new Date());
        tipsMapper.tipsAdd(tips);
        return "提示添加成功";
    }
    public Tips tipsQueryById(int id){
        Tips tips = tipsMapper.tipsQueryById(id);
        return tips;
    }
    public String tipsModify(@Param("tips_title")String tips_title,@Param("tips_content")String tips_content,@Param("tips_open")String tips_open,@Param("tips_id")int tips_id){
        Tips tips = new Tips();
        tips.setTips_id(tips_id);
        tips.setTips_title(tips_title);
        tips.setTips_content(tips_content);
        tips.setTips_open(tips_open);
        tipsMapper.tipsModify(tips);
        return "提示修改成功";
    }
    public List<Tips> tipsQueryAll(){
        List<Tips> tips = tipsMapper.tipsQueryAll();
        return tips;
    }
    public List<Tips> queryByTitle(String title){
        List<Tips> tipss = tipsMapper.tipsQueryByTitle(title);
        return tipss;
    }
}
